<template>
  <div class="music-list-wraper clearfix">
    <div class="music-item" v-for="item in newMusic" :key="item.id"
      @click="playMusic(item.id)">
      <img :src="item.picUrl" alt="">
      <h5 class="song-name">{{item.name}}</h5>
      <h5 class="author">{{item.song.artists[0].name}}</h5>
      <div class="icon-wrap"><span class="iconfont iconbofang1"></span></div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    newMusic: {
      type: Array,
      defaut() {
        return []
      }
    }
  },
  methods: {
    playMusic(id) {
      this.$store.dispatch('getPlayUrl', id)
    }
  }
}
</script>

<style lang="scss" scoped>
.music-list-wraper {
  width: 110%;
  padding-left: 10px;
  overflow: hidden;
  .music-item {
    position: relative;
    float: left;
    width: 50%;
    height: 80px;
    margin-bottom: 15px;
    cursor: pointer;
    transition: background-color 0.5s;
    &:hover {
      background-color: #f5f5f5;
      .icon-wrap {
        opacity: 0.8;
      }
    }
    img {
      float: left;
      width: 80px;
      margin-right: 10px;
    }
    h5 {
      font-weight: 400;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .song-name {
      font-size: 16px;
      margin: 8px 0 28px 0;
    }
    .author {
      font-size: 14px;
      color: #666;
    }
    .icon-wrap {
      position: absolute;
      top: 50%;
      transform: translateY(-50%);
      left: 25px;
      width: 30px;
      height: 30px;
      line-height: 30px;
      text-align: center;
      border-radius: 50%;
      background-color: #fff;
      opacity: 0;
      transition: opacity 0.7s;
      .iconbofang1 {
        position: relative;
        left: 2px;
        color: #dd6d60;
      }
    }
  }
}
</style>